function t(t) {
    if (Array.isArray(t)) {
        for (var a = 0, e = Array(t.length); a < t.length; a++) e[a] = t[a];
        return e;
    }
    return Array.from(t);
}

var a = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}, e = getApp();

Page({
    data: {
        typeList: [],
        type_id: "",
        loadPage: 1,
        lastPage: 0,
        list: [],
        inLoad: !0,
        my_position: 0,
    },
    onLoad: function(t) {
        var i = this;
       // console.log(t.showtabbar)
        wx.showLoading({
            title: "加载中..."
        }), 
        i.getTypeList(), 
        i.setData({
            step_unit:"里",
            haveTeam: false,
            showbar:t.showtabbar
        })
       // console.log(i.data.showbar)
    },
    onShow: function() {
        var t = this;
        wx.hideHomeButton()
        if (!this.data.haveTeam && 2 === this.data.type_id) {
            var a = e.userdetails.teamID && "0" !== e.userdetails.teamID && 0 !== e.userdetails.teamID;
            a && this.setData({
                haveTeam: a,
                loadPage: 1
            }, function() {
                t.getList();
            });
        }
    },
    tabbarSet: function() {
        if (e.individualityConf && e.individualityConf.tabbarSet) {
            var t = e.individualityConf.tabbarSet.findIndex(function(t) {
                return "27" === t.Type;
            });
            this.setData({
                tabIdx: t,
                loginSuccess: 0
            });
        }
    },
    getTypeList: function() {
        var t = this, a = [ 
        //     {
        //     name: "队伍排行榜",
        //     id: 2
        // }, 
        {
            name: "个人排行榜",
            id: 0
        }, {
            name: "今日排行榜",
            id: 1
        } ];
        this.setData({
            typeList: a,
            type_id: a[0].id
        }, function() {
            t.getList();
        });
    },
    switchType: function(t) {
        var a = this;
        t.currentTarget.dataset.id !== this.data.type_id && this.setData({
            type_id: t.currentTarget.dataset.id,
            loadPage: 1
        }, function() {
            a.getList();
        });
    },
    getList: function() {

        var i = this;
 
            
        wx.showLoading({
          title: '加载中...',
        })
        this.setData({
            inLoad: !0,
            lastPage:0
        }), 1 === this.data.loadPage && this.setData({
            list: [],
            my_position: 0
        })
            if(i.data.type_id==0){
                wx.request({
                    url: e.domain + "ssm/appWebServ/feet/list",
                    data: {
                      appid: e.appid,
                      openid: e.openid,
                      currentPageNbr: i.data.loadPage,
                      pageSize: 10
                    },
                    header: {
                      'content-type': 'application/json' // 默认值
                    },
                    success (res) {
                      
                      console.log(res)
                      i.setData({
                        inLoad: !1,
                        list: [].concat(i.data.list, res.data.list),
                        loadPage: i.data.loadPage + 1,
                        my_position: res.data.rank,
                        lastPage:i.data.loadPage==res.data.page.totalPages?1:0
                      });
                    },
                    complete (r) {
                        wx.hideLoading()
                    }
                  })
            }
            if(i.data.type_id==1){
                wx.request({
                    url: e.domain + "ssm/appWebServ/feet/curlist",
                    data: {
                      appid: e.appid,
                      openid: e.openid,
                      currentPageNbr: i.data.loadPage,
                      pageSize: 10
                    },
                    header: {
                      'content-type': 'application/json' // 默认值
                    },
                    success (res) {
                      console.log(res)
                      i.setData({
                        inLoad: !1,
                        list: [].concat(i.data.list, res.data.list),
                        loadPage: i.data.loadPage + 1,
                        my_position: res.data.rank,
                        lastPage:i.data.loadPage==res.data.page.totalPages?1:0
                      });
                    },
                    complete (r) {
                        wx.hideLoading()
                    }
                  })
            }
        

        // var s = {
        //         url: "flat/sport_step/user_top_rank_list",
        //         access_token: e.user_token,
        //         page: i.data.loadPage,
        //         perpage: 10
        //     };
        //     i.data.teamid ? s.team_id = i.data.teamid : s.get_today_top_rank = i.data.type_id, 
        //     i.data.active_id && (s.active_id = i.data.active_id), a.default.ajax({
        //         url: "jump",
        //         data: s,
        //         success: function(a) {
        //             if (wx.hideLoading(), i.setData({
        //                 inLoad: !1
        //             }), a.data) {
        //                 var e = a.data.user_list.data;
        //                 i.setData({
        //                     list: [].concat(t(i.data.list), t(e)),
        //                     lastPage: a.data.user_list.is_lastpage,
        //                     loadPage: i.data.loadPage + 1,
        //                     my_position: a.data.my_position,
        //                     team_need_average: a.data.team_need_average || !1
        //                 });
        //             } else i.setData({
        //                 lastPage: !0
        //             });
        //         }
        //     });

    },
    adinit: function() {
        var t = this;
    },
    adLoad: function() {
        console.log("原生模板广告加载成功");
    },
    adError: function(t) {
        console.log("原生模板广告加载失败", t);
    },
    onPullDownRefresh: function() {
        var t = this;
        this.setData({
            loadPage: 1
        }, function() {
            t.getList(), wx.stopPullDownRefresh();
        });
    },
    onReachBottom: function() {
        var i=this
        if(i.data.lastPage==0){
            this.getList();
        }
        
    },
    // clickItem: function(t) {
    //     if (!t.currentTarget.dataset.teamid) return !1;
    //     var a = "/pages/rankingList/rankingList?teamid=" + t.currentTarget.dataset.teamid + "&teamname=" + t.currentTarget.dataset.teamname;
    //     this.data.active_id && (a = a + "&active_id=" + this.data.active_id), this.data.no_ad && (a += "&no_ad=1"), 
    //     wx.navigateTo({
    //         url: a
    //     });
    // }
});